package com.onjob.employment;


import org.hibernate.Query;

import util.dao.HibernateDaoImpl;

public class PersonInfoDaoImpl extends HibernateDaoImpl<PersonInfo, String>
		implements PersonInfoDao {

	@Override
	public PersonInfo findByType(String string,String type) {
		Query query = this.getSession().createQuery(
				" from " + PersonInfo.class.getName() + " p where p."+type+"=:type");
		query.setString("type", string);
		
		return (PersonInfo) query.uniqueResult();
	}
	@Override
	public PersonInfo findByTypes(String string,String type) {
		Query query = this.getSession().createQuery(
				" from " + PersonInfo.class.getName() + " p where p.userId.id=:type");
		query.setString("type",string);
		
		return (PersonInfo) query.uniqueResult();
	}
	@Override
	public PersonInfo findByTypes(String string1, String string2, String type1,
			String type2) {
		Query query = this.getSession().createQuery(
				" from " + PersonInfo.class.getName() + " p where p."+type1+"=:type1 and p."+type2+"=:type2");
		query.setString("type1", string1);
		query.setString("type2", string2);
		return (PersonInfo)query.uniqueResult();
	}
	
	
//	@Override
//	public PersonInfo findByName(String name) {
//		Query query  = this.getSession().createQuery(" from "+PersonInfo.class.getName()+" p where p.personName")
//	}

}
